<script lang="ts" setup>
import { reactive, ref, watch } from "vue"
import {
  createComboDataApi,
  updateComboDataApi,
  getComboDataApi,
  uploadComboImageList,
  uploadComboImageListMin,
  getreportIdListApi
} from "@/api/stock-operation/comboSet"
import { type IGetComboData } from "@/api/combo/types/combo"
import { type FormInstance, type FormRules, ElMessage } from "element-plus"
import { Search, Refresh, CirclePlus, Download, RefreshRight } from "@element-plus/icons-vue"
import { usePagination } from "@/hooks/usePagination"
import Editor from "@/components/RichText/index.vue" // 引入富文本
import { Plus } from "@element-plus/icons-vue"
import { useComboSourceStore } from "@/store/modules/comboSource"
defineOptions({
  name: "XcxYsList"
})
const fileList = ref<any>([]) /**图片列表 */
// const userStore = useUserStore()
const loading = ref<boolean>(false)
const { paginationData, handleCurrentChange, handleSizeChange } = usePagination()
//#region 增
const dialogVisible = ref<boolean>(false)
const formRef = ref<FormInstance | null>(null)
const formData = reactive<any>({
  data: {
    agreement: "<p><br></p>",
    info: "<p><br></p>",
    userIds: []
  }
})
const formRules: FormRules = reactive({
  name: [{ required: true, trigger: "blur", message: "请输入套餐名称" }],
  code: [{ required: true, trigger: "blur", message: "请输入编码" }],
  superCode: [{ required: true, trigger: "blur", message: "请输入上级编码" }],
  source: [{ required: true, trigger: "change", message: "请输入套餐来源" }],
  operator: [{ required: true, trigger: "change", message: "请输入运营商" }],
  report: [{ required: true, trigger: "change", message: "请选择是否是报备套餐" }],
  state: [{ required: true, trigger: "change", message: "请选择是否上架" }],
  isOpen: [{ required: true, trigger: "change", message: "请选择是否对分销商开放" }],
  // userIds: [{ required: true, trigger: "blur", message: "请填选择分销商" }],
  souceUrl: [{ required: true, trigger: "blur", message: "请填写下单链接" }],
  type: [{ required: true, trigger: "change", message: "请选择类型" }]
})
const handleAdd = () => {
  dialogVisible.value = true
  getreportIdList()
}
const handleCreate = () => {
  formRef.value?.validate((valid: boolean) => {
    if (valid) {
      uploadFuc()
    } else {
      return false
    }
  })
}

//#endregion

//#region 删
// const handleDelete = (row: IGetComboData) => {
//   ElMessageBox.confirm(`正在删除套餐：${row.name}，确认删除？`, "提示", {
//     confirmButtonText: "确定",
//     cancelButtonText: "取消",
//     type: "warning"
//   }).then(() => {
//     deleteComboDataApi(row.id).then(() => {
//       ElMessage.success("删除成功")
//       getTableData()
//     })
//   })
// }
//#endregion

//#region 改
const currentUpdateId = ref<undefined | string>(undefined)

const handleUpdate = (row: any) => {
  console.log(row)
  currentUpdateId.value = row.id
  getreportIdList()
  formData.data = JSON.parse(JSON.stringify(row)) // 赋值需要深拷贝
  if (row.image) {
    fileList.value = row.image?.split(",").map((item: any) => {
      return {
        url: `http://fansitexitong.cn/image/${item}`
        // url: `http://192.168.31.143:8080/image/${item}`
      }
    })
  }
  if (row.image) {
    fileList.value = row.image?.split(",").map((item: any) => {
      return {
        url: `http://fansitexitong.cn/image/${item}`
        // url: `http://192.168.31.143:8080/image/${item}`
      }
    })
  }
  if (row.imgBackground) {
    fileList1.value = row.imgBackground?.split(",").map((item: any) => {
      return {
        url: `http://fansitexitong.cn/image/${item}`
        // url: `http://192.168.31.143:8080/image/${item}`
      }
    })
  }
  if (row.imgVerify) {
    fileList2.value = row.imgVerify?.split(",").map((item: any) => {
      return {
        url: `http://fansitexitong.cn/image/${item}`
        // url: `http://192.168.31.143:8080/image/${item}`
      }
    })
  }
  if (row.userIds) {
    formData.data.userIds = row.userIds.split(",")
  } else {
    formData.data.userIds = []
  }

  formData.data.id = currentUpdateId.value
  dialogVisible.value = true
}
//#endregion

//#region 查
const tableData = ref<IGetComboData[]>([])
const searchFormRef = ref<FormInstance | null>(null)
const searchData = reactive({
  name: "",
  sku: "",
  superSku: "",
  state: "true",
  report: "是"
  // team: userStore.teamName ? userStore.teamName : ""
})
const getTableData = () => {
  loading.value = true
  getComboDataApi({
    page: paginationData.currentPage,
    size: paginationData.pageSize,
    name: searchData.name,
    report: searchData.report
  })
    .then((res) => {
      paginationData.total = res.data.total
      tableData.value = res.data.list
    })
    .catch(() => {
      tableData.value = []
    })
    .finally(() => {
      loading.value = false
    })
}
const handleSearch = () => {
  if (paginationData.currentPage === 1) {
    getTableData()
  }
  paginationData.currentPage = 1
}
const resetSearch = () => {
  searchFormRef.value?.resetFields()
  if (paginationData.currentPage === 1) {
    getTableData()
  }
  paginationData.currentPage = 1
}
const handleRefresh = () => {
  getTableData()
}
//#endregion
/**套餐主图上传 */
const handleChageImg = (file: any, resfileList: any) => {
  const size = ref(10)
  const fileSizeFlag = file.size / 1024 / 1024 < size.value
  if (!fileSizeFlag) {
    ElMessage.error(`请上传不大于${size.value}M的图片!`)
    fileList.value = []
  } else {
    fileList.value = resfileList
  }
}

// 预览图片
const dialogImageUrl = ref("") /**预览url  */
const dialogVisible1 = ref(false) /**预览弹窗 */
const handlePictureCardPreview = (file: any) => {
  dialogImageUrl.value = file.url
  dialogVisible1.value = true
}
// 移除图片
const handleRemove = (file: any) => {
  const list = fileList.value
  for (const i in list) {
    if (list[i].uid === file.uid) {
      list.splice(i, 1)
    }
  }
  fileList.value = list
}
/**详情图上传 */
const fileList1 = ref<any>([]) /**图片列表 */
const dialogVisible4 = ref<boolean>(false)
const dialogImageUrl4 = ref<any>("")

const handleChageImg1 = (file: any, resfileList: any) => {
  const size = ref(10)
  const fileSizeFlag = file.size / 1024 / 1024 < size.value
  if (!fileSizeFlag) {
    ElMessage.error(`请上传不大于${size.value}M的图片!`)
    fileList1.value = []
  } else {
    fileList1.value = resfileList
  }
}

const handleRemove1 = (file: any) => {
  const list = fileList1.value
  for (const i in list) {
    if (list[i].uid === file.uid) {
      list.splice(i, 1)
    }
  }
  fileList1.value = list
}

const handlePictureCardPreview1 = (uploadFile: any) => {
  dialogImageUrl4.value = uploadFile.url!
  dialogVisible4.value = true
}

/**二确图 */
const fileList2 = ref<any>([]) /**图片列表 */
const dialogVisible5 = ref<boolean>(false)
const dialogImageUrl5 = ref<any>("")

const handleChageImg2 = (file: any, resfileList: any) => {
  const size = ref(10)
  const fileSizeFlag = file.size / 1024 / 1024 < size.value
  if (!fileSizeFlag) {
    ElMessage.error(`请上传不大于${size.value}M的图片!`)
    fileList2.value = []
  } else {
    fileList2.value = resfileList
  }
}

const handleRemove2 = (file: any) => {
  const list = fileList2.value
  for (const i in list) {
    if (list[i].uid === file.uid) {
      list.splice(i, 1)
    }
  }
  fileList2.value = list
}

const handlePictureCardPreview2 = (uploadFile: any) => {
  dialogImageUrl5.value = uploadFile.url!
  dialogVisible5.value = true
}

//确定上传
const uploadFuc = async () => {
  if (fileList.value.length === 0) {
    ElMessage.error("请上传引流图")
    return
  }
  if (fileList1.value.length === 0) {
    ElMessage.error("请上传落地页")
    return
  }
  if (fileList2.value.length === 0) {
    ElMessage.error("请上传二确图")
    return
  }
  const fileData = new FormData()
  fileList.value.forEach((file: any) => {
    fileData.append("file", file.raw)
  })
  if (fileList.value[0].status === "ready") {
    if (formData.data.report === "否") {
      await uploadComboImageList(fileData).then((res: any) => {
        if (res.code == 200) {
          formData.data.image = res.data.split("/image/")[1]
        }
      })
    }
    if (formData.data.report === "是") {
      await uploadComboImageListMin(fileData).then((res: any) => {
        if (res.code == 200) {
          formData.data.image = res.data.split("/image/")[1]
        }
      })
    }
  }
  const fileData1 = new FormData()
  fileList1.value.forEach((file: any) => {
    fileData1.append("file", file.raw)
  })
  if (fileList1.value[0].status === "ready") {
    if (formData.data.report === "否") {
      await uploadComboImageList(fileData1).then((res: any) => {
        if (res.code == 200) {
          formData.data.imgBackground = res.data.split("/image/")[1]
        }
      })
    }
    if (formData.data.report === "是") {
      await uploadComboImageListMin(fileData1).then((res: any) => {
        if (res.code == 200) {
          formData.data.imgBackground = res.data.split("/image/")[1]
        }
      })
    }
  }
  const fileData2 = new FormData()
  fileList2.value.forEach((file: any) => {
    fileData2.append("file", file.raw)
  })
  if (fileList2.value[0].status === "ready") {
    if (formData.data.report === "否") {
      await uploadComboImageList(fileData2).then((res: any) => {
        if (res.code == 200) {
          formData.data.imgVerify = res.data.split("/image/")[1]
        }
      })
    }
    if (formData.data.report === "是") {
      await uploadComboImageListMin(fileData2).then((res: any) => {
        if (res.code == 200) {
          formData.data.imgVerify = res.data.split("/image/")[1]
        }
      })
    }
  }
  console.log(formData.data.userIds, 19938)

  if (currentUpdateId.value === undefined) {
    await createComboDataApi({
      ...formData.data,
      userIds: formData.data.userIds.join()
    }).then((res: any) => {
      if (res.code == 200) {
        fileList.value = []
        fileList1.value = []
        fileList2.value = []
        ElMessage.success("新增成功")
        dialogVisible.value = false
        getTableData()
        getreportIdList()
      }
    })
  } else {
    await updateComboDataApi({
      ...formData.data,
      userIds: formData.data.userIds.join()
    }).then((res: any) => {
      if (res.code == 200) {
        fileList.value = []
        fileList1.value = []
        fileList2.value = []
        ElMessage.success("修改成功")
        dialogVisible.value = false
        getTableData()
        getreportIdList()
      }
    })
  }
}
/** 监听分页参数的变化 */
watch([() => paginationData.currentPage, () => paginationData.pageSize], getTableData, { immediate: true })

/**department END */
// console.log(departTeam.value)

// ** 清除规则报错信息
const clearValidate = () => {
  formRef.value?.clearValidate()
  formRef.value?.resetFields()
}
const resetForm = () => {
  currentUpdateId.value = undefined
  formData.data = { userIds: [] }
  formData.data.agreement = "<p><br></p>"
  formData.data.info = "<p><br></p>"
  fileList.value = []
  fileList1.value = []
  fileList2.value = []
  clearValidate()
}

const getMsgXY = (val: any) => {
  if (val) {
    formData.data.agreement = val
  }
}
const getMsgNY = (val: any) => {
  if (val) {
    formData.data.info = val
  }
}
/** 套餐来源数据获取 */
const comboSource = ref<any>([])
const comboSourceStore = useComboSourceStore()
comboSourceStore.getCsourceFn()
watch(
  [() => comboSourceStore.comboSourceListStore],
  (newValue) => {
    comboSource.value = newValue.flat()
  },
  {
    immediate: true
  }
)
// 报备套餐id
const reportIdList = ref<any>([])
const getreportIdList = () => {
  getreportIdListApi().then((res) => {
    //修改时，报备套餐去除自身，防止自身报备自身
    if (currentUpdateId.value) {
      reportIdList.value = res.data.filter((item: any) => item.id !== currentUpdateId.value)
    } else {
      reportIdList.value = res.data
    }
  })
}
const activeName = ref("report")
const handleClick = (tab: any) => {
  paginationData.currentPage = 1
  // console.log(tab.paneName)
  if (tab.paneName === "report") {
    searchData.report = "是"
  }
  if (tab.paneName == "sahre") {
    searchData.report = "否"
  }

  getTableData()
}
/**代理数据 */
import { getUserIdList } from "@/api/combo"

const userIdList = ref<any>([])
const userListEffect = () => {
  getUserIdList({}).then((res: any) => {
    console.log(res)
    userIdList.value = res.data
  })
}
userListEffect()
const changeOpen = (val: any) => {
  if (val === "否" || val == null) {
    formData.data.userIds = []
  }
}
</script>

<template>
  <div class="app-container">
    <el-card v-loading="loading" shadow="never" class="search-wrapper">
      <el-form ref="searchFormRef" :inline="true" :model="searchData">
        <el-form-item prop="name" label="套餐名">
          <el-input v-model.trim="searchData.name" placeholder="请输入" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
          <el-button :icon="Refresh" @click="resetSearch">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card v-loading="loading" shadow="never">
      <div class="toolbar-wrapper">
        <div>
          <el-button type="primary" :icon="CirclePlus" @click="handleAdd">添加套餐</el-button>
        </div>
        <div>
          <el-tooltip content="下载">
            <el-button type="primary" :icon="Download" circle />
          </el-tooltip>
          <el-tooltip content="刷新表格">
            <el-button type="primary" :icon="RefreshRight" circle @click="handleRefresh" />
          </el-tooltip>
        </div>
      </div>
      <div class="table-wrapper">
        <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
          <el-tab-pane label="报备套餐" name="report" />
          <el-tab-pane label="用户端展示套餐" name="sahre" />
        </el-tabs>
        <el-table :data="tableData">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column prop="id" label="ID" align="center" />
          <el-table-column prop="image" label="引流图" align="center">
            <template #default="scope">
              <!-- http://192.168.1.10:8080/   http://fansitexitong.cn-->
              <img
                :src="`http://fansitexitong.cn/image/${scope.row.image?.split(',')[0]}`"
                alt=""
                width="80"
                height="80"
              />
            </template>
          </el-table-column>
          <el-table-column prop="name" label="套餐名" align="center" />
          <!-- <el-table-column prop="code" label="套餐编码" align="center" /> -->
          <el-table-column prop="superName" label="上级套餐名字" align="center" />
          <el-table-column prop="superCode" label="上级套餐编码" align="center" />
          <el-table-column prop="source" label="套餐来源" align="center" />
          <el-table-column prop="operator" label="运营商" align="center">
            <template #default="scope">
              <span v-if="scope.row.operator == 1">移动</span>
              <span v-else-if="scope.row.operator == 2">联通</span>
              <span v-else-if="scope.row.operator == 3">电信</span>
              <span v-else-if="scope.row.operator == 4">广电</span>
              <span v-else>无</span>
            </template>
          </el-table-column>
          <el-table-column prop="type" label="类型" align="center" />
          <el-table-column prop="state" label="套餐状态" align="center">
            <template #default="scope">
              <span :style="{ color: scope.row.state === '上架' ? '#67c23a' : '#f56c6c' }">{{ scope.row.state }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="isOpen" label="分销商开放" align="center" />
          <el-table-column fixed="right" label="操作" width="200" align="center">
            <template #default="scope">
              <el-button type="primary" text bg size="small" @click="handleUpdate(scope.row)">修改</el-button>
              <!-- <el-button type="danger" text bg size="small" @click="handleDelete(scope.row)">删除</el-button> -->
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pager-wrapper">
        <el-pagination
          background
          :layout="paginationData.layout"
          :page-sizes="paginationData.pageSizes"
          :total="paginationData.total"
          :page-size="paginationData.pageSize"
          :currentPage="paginationData.currentPage"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>
    <!-- 新增/修改 -->
    <el-dialog
      v-model="dialogVisible"
      :title="currentUpdateId === undefined ? '新增套餐' : '修改套餐'"
      @close="resetForm"
      width="80%"
    >
      <el-form
        class="forminput"
        ref="formRef"
        :model="formData.data"
        :rules="formRules"
        label-width="100px"
        label-position="left"
      >
        <el-form-item prop="superName" label="上级套餐名字">
          <el-input v-model="formData.data.superName" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="superCode" label="上级套餐编码">
          <el-input v-model="formData.data.superCode" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="source" label="套餐来源">
          <el-select v-model="formData.data.source" clearable placeholder="请选择" style="width: 240px">
            <el-option v-for="item in comboSource" :key="item.id" :label="item.name" :value="item.name" />
          </el-select>
        </el-form-item>
        <el-form-item prop="name" label="套餐名">
          <el-input v-model="formData.data.name" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="code" label="套餐编码">
          <el-input v-model="formData.data.code" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="operator" label="运营商">
          <el-select v-model="formData.data.operator" clearable placeholder="请选择" style="width: 240px">
            <el-option :key="1" label="移动" :value="1" />
            <el-option :key="2" label="联通" :value="2" />
            <el-option :key="3" label="电信" :value="3" />
            <el-option :key="4" label="广电" :value="4" />
          </el-select>
        </el-form-item>
        <el-form-item prop="report" label="是否是报备套餐">
          <el-select v-model="formData.data.report" clearable filterable placeholder="请选择" style="width: 240px">
            <el-option :key="1" label="是" value="是" />
            <el-option :key="2" label="否" value="否" />
          </el-select>
        </el-form-item>
        <el-form-item prop="reportId" label="报备套餐" v-if="formData.data.report === '否'">
          <el-select v-model="formData.data.reportId" filterable clearable placeholder="请选择" style="width: 240px">
            <el-option v-for="item in reportIdList" :key="item.name" :label="item.name" :value="item.id + ''" />
          </el-select>
        </el-form-item>
        <el-form-item prop="souceUrl" label="下单链接" v-if="formData.data.report === '是'">
          <el-input v-model="formData.data.souceUrl" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="line" label="抽取线">
          <el-input v-model="formData.data.line" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="nums" label="抽取数">
          <el-input v-model="formData.data.nums" placeholder="请输入" />
        </el-form-item>
        <el-form-item prop="image">
          <template #label>
            <span>引流图</span>
            <el-tooltip class="box-item" effect="customized" placement="bottom">
              <template #content>
                引流图，建议尺寸：375px * 375px 用于展示产品缩略图，以及产品详情页顶部的轮播图</template
              >
              <el-icon style="cursor: pointer"><InfoFilled /></el-icon>
            </el-tooltip>
          </template>
          <el-upload
            :auto-upload="false"
            :file-list="fileList"
            :show-file-list="true"
            list-type="picture-card"
            :limit="1"
            accept="image/*"
            :on-change="handleChageImg"
            :disabled="fileList.length != 0"
          >
            <el-icon><Plus /></el-icon>
            <template #file="{ file }">
              <div>
                <img class="el-upload-list__item-thumbnail" :src="file.url" />
                <span class="el-upload-list__item-actions">
                  <span class="el-upload-list__item-delete" @click="handleRemove(file)">
                    <el-icon>
                      <Delete />
                    </el-icon>
                  </span>
                  <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
                    <el-icon>
                      <zoom-in />
                    </el-icon>
                  </span>
                </span>
              </div>
            </template>
          </el-upload>
        </el-form-item>
        <el-form-item prop="imgBackground">
          <template #label>
            <span>落地页</span>
            <el-tooltip class="box-item" effect="customized" placement="bottom">
              <template #content> 落地页，建议尺寸 宽750px 高度随内容变化 用于产品详情页的详情图 </template>
              <el-icon style="cursor: pointer"><InfoFilled /></el-icon>
            </el-tooltip>
          </template>
          <el-upload
            :auto-upload="false"
            v-model:file-list="fileList1"
            action="api/order/package/upload"
            list-type="picture-card"
            :on-change="handleChageImg1"
            accept="image/*"
            :disabled="fileList1.length != 0"
          >
            <el-icon><Plus /></el-icon>
            <template #file="{ file }">
              <div>
                <img class="el-upload-list__item-thumbnail" :src="file.url" />
                <span class="el-upload-list__item-actions">
                  <span class="el-upload-list__item-delete" @click="handleRemove1(file)">
                    <el-icon>
                      <Delete />
                    </el-icon>
                  </span>
                  <span class="el-upload-list__item-preview" @click="handlePictureCardPreview1(file)">
                    <el-icon>
                      <zoom-in />
                    </el-icon>
                  </span>
                </span>
              </div>
            </template>
          </el-upload>

          <el-dialog v-model="dialogVisible4">
            <img w-full :src="dialogImageUrl4" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item prop="imgVerify">
          <template #label>
            <span>二确图</span>
          </template>
          <el-upload
            :auto-upload="false"
            v-model:file-list="fileList2"
            action="api/order/package/upload"
            list-type="picture-card"
            :on-change="handleChageImg2"
            accept="image/*"
            :disabled="fileList2.length != 0"
          >
            <el-icon><Plus /></el-icon>
            <template #file="{ file }">
              <div>
                <img class="el-upload-list__item-thumbnail" :src="file.url" />
                <span class="el-upload-list__item-actions">
                  <span class="el-upload-list__item-delete" @click="handleRemove2(file)">
                    <el-icon>
                      <Delete />
                    </el-icon>
                  </span>
                  <span class="el-upload-list__item-preview" @click="handlePictureCardPreview2(file)">
                    <el-icon>
                      <zoom-in />
                    </el-icon>
                  </span>
                </span>
              </div>
            </template>
          </el-upload>

          <el-dialog v-model="dialogVisible5">
            <img w-full :src="dialogImageUrl5" alt="Preview Image" />
          </el-dialog>
        </el-form-item>
        <el-form-item prop="type" label="类型">
          <el-select v-model="formData.data.type" clearable placeholder="请选择" style="width: 240px">
            <el-option :key="1" label="活动" value="活动" />
            <el-option :key="2" label="流量包" value="流量包" />
          </el-select>
        </el-form-item>
        <el-form-item prop="state" label="套餐状态">
          <el-select v-model="formData.data.state" clearable placeholder="请选择" style="width: 240px">
            <el-option :key="1" label="上架" value="上架" />
            <el-option :key="2" label="下架" value="下架" />
          </el-select>
        </el-form-item>
        <el-form-item prop="agreement" label="协议">
          <Editor :value="formData.data.agreement" @updateValue="getMsgXY" />
        </el-form-item>
        <el-form-item prop="info" label="成功弹出内容">
          <Editor :value="formData.data.info" @updateValue="getMsgNY" />
        </el-form-item>
        <el-form-item prop="preLink" label="成功弹窗预览" v-if="currentUpdateId">
          <p style="margin: 0">
            {{ `http://fansitexitong.cn/company/#/stockOrderPreView?pid=${currentUpdateId}` }}
          </p>
        </el-form-item>
        <el-form-item prop="isOpen" label="分销商开放" v-if="formData.data.report === '否'">
          <el-select
            @change="changeOpen"
            v-model="formData.data.isOpen"
            clearable
            placeholder="请选择"
            style="width: 400px"
          >
            <el-option :key="1" label="是" value="是" />
            <el-option :key="2" label="否" value="否" />
          </el-select>
        </el-form-item>
        <el-form-item prop="userIds" label="可销售分销商" v-if="formData.data.report === '否'">
          <el-select
            :disabled="formData.data.isOpen === '否' || formData.data.isOpen == null"
            v-model="formData.data.userIds"
            clearable
            filterable
            multiple
            placeholder="请选择"
            style="width: 240px"
          >
            <el-option
              v-for="item in userIdList"
              :key="item.user_id"
              :label="item.user_name"
              :value="item.user_id + ''"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleCreate">确认</el-button>
      </template>
    </el-dialog>
    <el-dialog v-model="dialogVisible1">
      <img w-full :src="dialogImageUrl" alt="Preview Image" />
    </el-dialog>
  </div>
</template>

<style lang="scss" scoped>
.search-wrapper {
  margin-bottom: 20px;
  :deep(.el-card__body) {
    padding-bottom: 2px;
  }
}

.toolbar-wrapper {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.table-wrapper {
  margin-bottom: 20px;
}

.pager-wrapper {
  display: flex;
  justify-content: flex-end;
}
.avatar-uploader .avatar {
  width: 178px;
  height: 178px;
  display: block;
}
.ageInput :deep(.el-input) {
  width: 20% !important;
}

.forminput {
  :deep(.el-form-item__label) {
    width: 130px !important;
  }
}

:deep(.el-popper) {
  max-width: 50% !important;
}
:deep(.el-cascader) {
  width: 567px !important;
}
.text-ellipsis {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}
</style>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
}

.el-popper.is-customized {
  /* Set padding to ensure the height is 32px */
  padding: 6px 12px;
  background: linear-gradient(90deg, rgb(159, 229, 151), rgb(204, 229, 129));
}

.el-popper.is-customized .el-popper__arrow::before {
  background: linear-gradient(45deg, #b2e68d, #bce689);
  right: 0;
}
</style>
